<?php
/**
 * This file is part of DomMonitor.
 * 
 * DomMonitor is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * DomMonitor is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with DomMonitor.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * @link http://inditel.ee/
 * @copyright 2007-2009 Inditel Meedia OÜ
 * @author Oliver Leisalu <oliver@inditel.ee>
 */

/**
* @author Oliver Leisalu, Inditel Meedia OÜ
* @package DomMonitor
*/
class DomMonitorEntry {
	
	private $group;
	
	private $start;
	
	private $end;
	
	private $description;
	
	private $realTotalTime;
	
	private $totalTime;
	
	private $subEntries = array();
	
	public static function c( $group, $description ) {
		return new DomMonitorEntry( $group, $description );
	}
	
	public function __construct( $group, $description ) {
		$this->group = $group;
		$this->description = $description;
		$this->start = microtime(true);
	}

	public function end() {
		$this->end = microtime(true);
		$this->realTotalTime = $this->end - $this->start;
		$this->totalTime = $this->realTotalTime;
		DomMonitor::register( $this );
	}
	
	public function setTotalTime( $time ) {
		$this->totalTime = $time;
	}
	
	public function registerSubEntry( DomMonitorEntry $entry ) {
		$this->subEntries[] = $entry;
	}
	
	public function __get( $var ) {
		return $this->$var;
	}
	
}
?>